package cn.z2huo.knowledge.basic.exception.finallyy;

/**
 * <p>守护线程中的 finally
 *
 * @author z2huo
 */
class DaemonFinallyTest {

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            try {
                System.out.println(Thread.currentThread().getName() + " daemon thread");
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            } finally {
                System.out.println(Thread.currentThread().getName() + " daemon finally");
            }
        });
        thread.setDaemon(true);

        thread.start();
        Thread.sleep(3000);

//        ExecutorService executorService = Executors.newCachedThreadPool();

        System.out.println(Thread.currentThread().getName() + "-退出");
    }

}
